<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>系统常态化运行评分系统</title>
    <link rel="stylesheet" href="../../component/pear/css/pear.css" />
    <style>
        .expand.pear-btn:hover {
            color: currentColor;
            background: none;
        }

        .expand.pear-btn {
            border: 1px solid rgba(255, 255, 255, 0)
        }

    </style>
        <script>
            var zbDetailArr = [{
                type: 1,
                name: '判断'
            },
            {
                type: 2,
                name: '数字'
            },
            {
                type: 3,
                name: '文本'
            },
            {
                type: 4,
                name: '日期'
            },
            ]
            function getZbDetailTypeName(zbDetailsType) {
                // 遍历 zbDetailArr 数组
                for (var i = 0; i < zbDetailArr.length; i++) {
                    // 检查 type 是否与传入的 zbDetailsType 匹配
                    if (zbDetailArr[i].type === zbDetailsType) {
                        // 如果找到匹配项，返回对应的 name
                        return zbDetailArr[i].name;
                    }
                }
                // 如果没有找到匹配项，可以返回一个默认值或者 null
                return null;
            }
        </script>
</head>

<body class="pear-container">
    <div id="div-ext">
        <div class="layer-top">
            <form class="layui-form" action="" onsubmit="return false" lay-filter="lay-info">
                <div class="layui-card">
                    <div class="layui-card-header" id="divHeader" style="float: right;">
                        <button id="btn" class="pear-btn pear-btn-md pear-btn-primary" lay-submit
                            lay-filter="lay-user-add">保存</button>
                    </div>
                </div>
                <div class="layui-card" style="margin-top: 10px;">
                    <input type="hidden" name="id" />
                    <div class="layui-form-item">
                        <label class="layui-form-label">指标描述</label>
                        <div class="layui-input-block">
                            <input disabled="disabled"  type="text" name="zbDetailsRemark" required 
                                placeholder="" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" title="指标数据的值单位">数据单位</label>
                        <div class="layui-input-block">
                            <input disabled="disabled"  type="text" name="zbDetailsUnit" required 
                                placeholder="" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" title="指标数据的值类型">数据类型</label>
                        <div class="layui-input-block">
                            <input disabled="disabled"  type="text" name="zbDetailsType" required 
                                placeholder="" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" title="指标数据是否具备自动获取的条件">自动获取</label>
                        <div class="layui-input-block">
                            <input disabled="disabled" type="checkbox" name="open" lay-skin="switch" lay-filter="switchTest" title="是|否">
                          </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" title="该指标考核的溯源方法步骤的详细描述">溯源方法</label>
                        <div class="layui-input-block">
                            <textarea id="remark" name="remark" placeholder="请输入指标溯源方法" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <script src="../../component/layui/layui.js"></script>
    <script src="../../component/pear/pear.js"></script>
    <script src="../../scripts/utils/request.js"></script>
    <script src="../../scripts/utils/auth.js"></script>
    <script src="../../scripts/utils/tinymceUtils.js"></script>
    <script>
        var $, table, form, drawer, popup, notice, laydate
        layui.use(['table', 'form', 'jquery', 'drawer', 'popup', 'notice', 'laydate', 'tinymce', 'layer'], function () {
            table = layui.table;
            form = layui.form;
            $ = layui.jquery;
            drawer = layui.drawer;
            popup = layui.popup;
            notice = layui.notice;
            laydate = layui.laydate;
            var tinymce = layui.tinymce;
            var layer = layui.layer;
            let selData = parent.getData();
            var remark = initTinymce(tinymce, 'remark', 2, selData.systemId);


            laydate.render({
                elem: '#pulishTime'
            });
            var index = parent.layer.getFrameIndex(window.name);
           console.log(selData,'++++++++++');
            form.val('lay-info', {
                "id": selData.id,
                "zbDetailsIsAuto": selData.zbDetailsIsAuto,
                "zbDetailsUnit": selData.zbDetailsUnit,
                "zbDetailsType": getZbDetailTypeName(selData.zbDetailsType),
                "zbDetailsRemark": selData.zbDetailsRemark,
                "remark": selData.zbDetailsFunction
            });
            /**
             * 新增/修改评分
             */
            form.on('submit(lay-user-add)', function (data) {
                let reqData = {
                    id: selData.id,
                    zbDetailsFunction: remark.getContent()
                }
                postAjax('/api/configZb/modifyZbDetailsFunction', reqData, function (response) {
                    parent.refresh();
                    parent.layer.close(index);
                }, null);
            });

        });

    </script>
</body>

</html>